package string;

import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author LIBOFEI
 * @ClassName GetImg
 * @description
 * @date 2020/11/18 14:03
 * @Version 1.0
 **/
public class GetImg  {

    static Pattern img = Pattern.compile("(<img[^>]*/>)");
    static Pattern src = Pattern.compile("src\\s*=\\s*\"?(.*?)(\"|>|\\s+)");
    static String content = "<p><img src=\"http://admin.kuaijilm.com/neditor/upload/image/20190704/1562230457432175.jpg\" alt=\"旅游行业_01.jpg\"/><img src=\"http://admin.kuaijilm.com/neditor/upload/image/20190704/1562230460871641.jpg\" alt=\"旅游行业_02.jpg\"/><img src=\"http://admin.kuaijilm.com/neditor/upload/image/20190704/1562230463768667.jpg\" alt=\"旅游行业_03.jpg\"/><img src=\"http://admin.kuaijilm.com/neditor/upload/image/20190704/1562230466826394.jpg\" alt=\"旅游行业_04.jpg\"/><img src=\"http://admin.kuaijilm.com/neditor/upload/image/20190704/1562230468155247.jpg\" alt=\"旅游行业_05.jpg\"/><img src=\"http://admin.kuaijilm.com/neditor/upload/image/20190704/1562230471140922.jpg\" alt=\"旅游行业_06.jpg\"/><img src=\"http://admin.kuaijilm.com/neditor/upload/image/20190704/1562230472354415.jpg\" alt=\"旅游行业_07.jpg\"/><img src=\"http://admin.kuaijilm.com/neditor/upload/image/20190704/1562230474891590.jpg\" alt=\"旅游行业_08.jpg\"/><img src=\"http://admin.kuaijilm.com/neditor/upload/image/20190704/1562230477270135.jpg\" alt=\"旅游行业_09.jpg\"/><img src=\"http://admin.kuaijilm.com/neditor/upload/image/20190704/1562230481660174.jpg\" alt=\"旅游行业_10.jpg\"/></p>";

    public static void main(String[] args) {
        Matcher m = img.matcher(content);
        StringBuffer b = new StringBuffer();
        while(m.find()){
            System.out.println(m.group());
            Matcher c = src.matcher(m.group());
            while(c.find()){
                System.out.println(c.group(1));
                content = content.replaceAll(c.group(1),"https:://hiker.eduhiker.com/aaaaaaaaa/"+ new Date().getTime() + ".jpg");
            }

        }
        System.out.println(content);
    }
}
